package org.feng.client.request;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Map;

/**
 * 菜品识别请求体 https://ai.baidu.com/ai-doc/IMAGERECOGNITION/tk3bcxbb0
 *
 * @author feng
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class DishesImageClassifyRequest  extends ImageClassifyRequest {
    private static final long serialVersionUID = 6097011380027484341L;

    /**
     * 返回结果top n,默认5.
     */
    private Integer topNum;

    /**
     * 默认0.95，可以通过该参数调节识别效果，降低非菜识别率.
     */
    private BigDecimal filterThreshold;

    @Override
    public String getPath() {
        return super.getPathPrefix() + "/v2/dish";
    }

    public void fillParmaMap(Map<String, Object> paramsMap) {
        super.fillParmaMap(paramsMap);
        if (topNum != null) {
            paramsMap.put("top_num", topNum);
        }
        if (filterThreshold != null) {
            paramsMap.put("filter_threshold", filterThreshold.setScale(2, RoundingMode.HALF_UP));
        }
    }
}
